package com.twu.biblioteca;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Created by sahelig on 12/06/14.
 */
public class UserInterfaceForApplication implements UserInterface
{
    public void display(String message)
    {
        System.out.println(message);
    }

    public String takeInput()throws IOException
    {
        InputStreamReader read = new InputStreamReader(System.in);
        BufferedReader in = new BufferedReader(read);
        String inputTaken=in.readLine();
        return inputTaken.trim();
    }
   public int takeInputForOption() throws IOException
   {
        this.display("\nEnter option:");
        int option = Integer.parseInt(this.takeInput().trim());
        return option;
    }

    public String takeUserInputForBookTitle() throws IOException
    {
        this.display("Enter book title:");
        return takeInput().trim();

    }

    public void displayBook(Book book) {


        this.display(book.toString());
    }


    public String takeInputForLibraryNumber()throws IOException{

        this.display("Enter Library Number:");
        return takeInput().trim();
    }

    public String takeInputForPassword()throws IOException{

        this.display("Enter password:");
        return takeInput().trim();
    }


    public void displayMovie(Movie movie)
    {

        display(movie.getMovieTitle()+" "+movie.getDirector()+" "+movie.getYear()+" "+movie.getRating());
    }

    @Override
    public String takeUserInputForMovieTitle() throws IOException {

        this.display("Enter movie title:");
        return takeInput().trim();
    }

    @Override
    public void displayUserInformation(String infoForCorrespondingLibraryNumber) {
        this.display("Library Number         Name             Email id             Phone Number");
        this.display("==============      =========          ==========           ===============");
        this.display(infoForCorrespondingLibraryNumber);
    }

    @Override
    public String takeUserInputForBookAuthor() throws IOException{

        this.display("Enter book author:");
        return this.takeInput().trim();
    }

    @Override
    public String takeUserInputForBookYear() throws IOException {
        this.display("Enter book publication year:");
        return this.takeInput().trim();
    }

    @Override
    public String takeUserInputForMovieDirector()throws IOException{
        this.display("Enter movie producer:");
        return this.takeInput().trim();
    }

    @Override
    public String takeUserInputForMovieYear() throws IOException{
        this.display("Enter Movie year:");
        return this.takeInput().trim();
    }

    @Override
    public String takeUserInputForMovieRating()throws IOException{

        this.display("Enter Movie rating:");
        return this.takeInput().trim();
    }


}

